
#include "guichan/widgets/imageButtonEx.hpp"

namespace gcn
{
	ImageButtonEx::ImageButtonEx(const string & fileMO, const string & fileMI, const string & fileMC):
	imgMouseOut(NULL),imgMouseIn(NULL),imgMouseClick(NULL)
	{
		imgMouseOut = gcn::Image::load(fileMO.c_str());
		imgMouseIn = gcn::Image::load(fileMI.c_str());
		imgMouseClick = gcn::Image::load(fileMC.c_str());

	// 	assert(imgMouseOut!=NULL);
	// 	assert(imgMouseIn!=NULL);
	// 	assert(imgMouseClick!=NULL);
		setSize(imgMouseClick->getWidth(),imgMouseClick->getHeight());
	}


	void ImageButtonEx::draw(Graphics* graphics)
	{
		if (isPressed())
		{
			if(imgMouseClick)
				graphics->drawImage(imgMouseClick, 0, 0);
		}
		else
		{
			if (mHasMouse)
			{
				if(imgMouseIn)
					graphics->drawImage(imgMouseIn, 0, 0);
			}
			else
			{
				if(imgMouseOut)
					graphics->drawImage(imgMouseOut, 0, 0);
			}
		}
	}
}